package com.csx;

import com.csx.base.MysqlUtils;
import com.csx.base.StragtegyProvider;
import com.csx.base.TidbAdapter;
import lombok.var;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Context {
    public static StragtegyProvider StragtegyProvider = new StragtegyProvider();
    public static TidbAdapter OdsSyncAdapter = new TidbAdapter();
    public static CheckDbDataTask CheckDbDataTask = new CheckDbDataTask();

    public static synchronized HashMap<String,String> getMysqlTables(){
        HashMap<String,String> rs= new HashMap<>();
        for(var table: MysqlUtils.getAllFullNameTables())  {
            if(!Context.StragtegyProvider.isBlackTable(Context.StragtegyProvider.parseDb(table), Context.StragtegyProvider.parseTable(table))) {
                rs.put(table.toLowerCase(),table);
            }
        }
        return rs;
    }
    public static synchronized HashMap<String,String> getTidbTables(){
        HashMap<String,String> rs= new HashMap<>();
        for(var table: Context.OdsSyncAdapter.getAllFullNameTables())  {
            if(!Context.StragtegyProvider.isBlackTable(Context.StragtegyProvider.parseDb(table), Context.StragtegyProvider.parseTable(table))) {
                rs.put(table.toLowerCase(), table);
            }
        }
        return rs;
    }
}
